package com.aoxin.controller.activity;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.aoxin.model.activity.SlfCash;
import com.aoxin.service.inter.activity.SlfCashService;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.Const;
import com.aoxin.util.enumerate.OperateType;
import com.aoxin.util.log.LogInfo;

/**
 * 更新提现历史记录
 * 
 * @author lop
 * @date 2018年5月7日 下午2:39:58
 */
@RestController
@RequestMapping("/web/slfcash/")
public class SlfCashController {

	@Autowired
	SlfCashService slfCashService;

	/**
	 * 查询提现历史记录
	 * 
	 * @param res
	 * @param slfcash
	 * @return
	 */
	@RequestMapping("getSlfCash")
	@LogInfo(operateType = OperateType.QUERY, content = "查询提现历史记录")
	public AjaxRes getSlfCash(AjaxRes res, SlfCash slfcash) {
		try {
			List<SlfCash> slfcashS = this.slfCashService.getSlfCash(slfcash);
			res.setSucceed(slfcashS, Const.DATA_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}

	/**
	 * 添加提现历史记录
	 * 
	 * @param res
	 * @param slfcash
	 * @return
	 */
	@RequestMapping("insertSelective")
	@LogInfo(operateType = OperateType.INSERT, content = " 添加提现历史记录")
	public AjaxRes insertSelective(AjaxRes res, Integer type) {
		try {
			this.slfCashService.insertSelectives(type);
			res.setSucceedMsg(Const.SAVE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	
	/**
	 * 添加提现历史记录
	 * 
	 * @param res
	 * @param slfcash
	 * @return
	 */
	@RequestMapping("insertCash")
	@LogInfo(operateType = OperateType.INSERT, content = " 添加提现历史记录")
	public AjaxRes insertCash(AjaxRes res, SlfCash slfCash) {
		try {
			this.slfCashService.insertSelective(slfCash);
			res.setSucceedMsg(Const.SAVE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}

	/**
	 * 更新提现历史记录状态
	 * 
	 * @param res
	 * @param recommendMoneyId
	 * @param state
	 * @return
	 */
	@RequestMapping("updateRecommendMoney")
	@LogInfo(operateType = OperateType.UPDATE, content = "更新提现历史记录状态")
	public AjaxRes updateSlfCash(AjaxRes res, @RequestParam("recommendMoneyId") List<Integer> recommendMoneyId, Integer state) {
		try {
			Integer integer = this.slfCashService.updateSlfCash(recommendMoneyId, state);
			res.setSucceed(integer, Const.UPDATE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}

}
